package parsing.yago;

import java.util.TreeMap;

import core.objects.Author;
import core.objects.Book;
import core.objects.Category;
import core.objects.City;
import core.objects.Country;
import core.objects.Publisher;
import core.objects.PublisherCategory;


public class ParsingEnvironment {

	/* set constants to estimate when each file portion begins 
	 * in progress bar display: */
	public static TreeMap<String, Integer> PROGRESSES_STARTING_POINT;
	/* set constants to estimate how much percentage each file
	 * takes in computation for progress bar display: */
	public static TreeMap<String, Integer> PROGRESSES_DURATIONS;
	
	/* parsing is only 50% of the job, need to populate database as well */
	
	private static TreeMap<String, Category> _categories;
	private static TreeMap<String, Book> _books;
	private static TreeMap<String, Author> _writers;
	private static TreeMap<String, PublisherCategory> _publisherCategories;
	private static TreeMap<String, Publisher> _publishers;
	private static TreeMap<String, Country> _countries;
	private static TreeMap<String, City> _cities;
	
	private static IParserProgress _parserProgress;
	
	//prevent from creating instance:
	private ParsingEnvironment() { }
	
	static {
		
		_categories = new TreeMap<String, Category>();
		_books = new TreeMap<String, Book>();
		_writers = new TreeMap<String, Author>();
		_publisherCategories = new TreeMap<String, PublisherCategory>();
		_publishers = new TreeMap<String, Publisher>();
		_countries = new TreeMap<String, Country>();
		_cities = new TreeMap<String, City>();
		
		PROGRESSES_STARTING_POINT = new TreeMap<String, Integer>();
		PROGRESSES_STARTING_POINT.put("yagoTaxonomy.tsv", 0);
		PROGRESSES_STARTING_POINT.put("yagoTransitiveType.tsv", 1);
		PROGRESSES_STARTING_POINT.put("yagoLiteralFacts.tsv", 21);
		PROGRESSES_STARTING_POINT.put("yagoWikipediaInfo.tsv", 24);
		PROGRESSES_STARTING_POINT.put("yagoLabels.tsv", 44);
		
		PROGRESSES_DURATIONS = new TreeMap<String, Integer>();
		PROGRESSES_DURATIONS.put("yagoTaxonomy.tsv", 1);
		PROGRESSES_DURATIONS.put("yagoTransitiveType.tsv", 20);
		PROGRESSES_DURATIONS.put("yagoLiteralFacts.tsv", 3);
		PROGRESSES_DURATIONS.put("yagoWikipediaInfo.tsv", 20);
		PROGRESSES_DURATIONS.put("yagoLabels.tsv", 6);
		
	}
		
	public static TreeMap<String, Category> getCategories() { return _categories; }
	public static TreeMap<String, Book> getBooks() { return _books; }
	public static TreeMap<String, Author> getWriters() { return _writers; }
	public static TreeMap<String, PublisherCategory> getPublisherCategories() { return _publisherCategories; }
	public static TreeMap<String, Publisher> getPublishers() { return _publishers; }
	public static TreeMap<String, Country> getCountries() { return _countries; }
	public static TreeMap<String, City> getCities() { return _cities; }
	
	public static void setParserProgress(IParserProgress progress) {
		_parserProgress = progress;
	}
	
	public static IParserProgress getParserProgress() {
		return _parserProgress;
	}
	
}
